<template>
  <div class="parmeter-page">
    <div class="header">
      <div class="header-center">
        <span>Z5pro 采样无人机</span>
        <ul>
          <li @click="goIndex">首页</li>
          <li @click="goPos(index)" v-for="(item, index) in navData" :class='isActive === index ? "active":""'>
            {{item.navtitle}}
          </li>
        </ul>
      </div>
    </div>
    <div class="parmeter-top" style="padding: 0"></div>
    <div class="img-show">
      <ul>
        <li>
          <img src="../../../assets/images/parameter/show1.jpg" alt="">
          <div class="word1">
            <span>360°全面防护</span>
            <div>无边界 自由探索</div>
          </div>
        </li>
        <li>
          <img src="../../../assets/images/parameter/show2.jpg" alt="">
          <div class="word2">
            <span>穿越狭窄路径</span>
          </div>
        </li>
        <li>
          <img src="../../../assets/images/parameter/show3.jpg" alt="">
          <div class="word1">
            <span>第一视角 操控自如</span>
          </div>
        </li>
        <li>
          <img src="../../../assets/images/parameter/show4.jpg" alt="">
          <div class="word2">
            <span>搭配多种挂载与传感器</span>
            <span>应用于多类工业场景</span>
          </div>
        </li>
      </ul>
    </div>
    <div class="parmeter-top">
      <p>技术参数</p>
    </div>
    <div class="parmeter-center">
      <div class="parmeter-box">
        <div class="parmeter-center-1">
          <p>飞行器</p>
          <div class="parmeter-center-2">
            <ul class="ul1">
              <li v-for="item in parameterData">{{item.name}}</li>
            </ul>
            <ul class="ul2">
              <li v-for="item in parameterData">{{item.paraData}}</li>
            </ul>
          </div>
        </div>
        <div class="parmeter-center-1">
          <p>飞行器1</p>
          <div class="parmeter-center-2">
            <ul class="ul1">
              <li v-for="item in parameterData1">{{item.name}}</li>
            </ul>
            <ul class="ul2">
              <li v-for="item in parameterData1">{{item.paraData}}</li>
            </ul>
          </div>
        </div>
      </div>
    </div>

    <!--<div class="parmeter-top" style="background: #f2f2f2">-->
    <!--<p>资源下载</p>-->
    <!--</div>-->
    <!--<div class="parmeter-center" style="background: #f2f2f2">-->
    <!--<div class="parmeter-box">-->
    <!--<div class="parmeter-center-1">-->
    <!--<p>INSPIRE 2 拍摄样片下载</p>-->
    <!--<div class="parmeter-center-2">-->
    <!--<ul class="ul1">-->
    <!--<li v-for="item in parameterData2">{{item.name}}-->
    <!--<span>{{item.time}}</span>-->
    <!--</li>-->
    <!--</ul>-->
    <!--<ul class="ul2">-->
    <!--<li v-for="item in parameterData2" style="height: 38px;font-size: 12px;">-->
    <!--<a href="">下载</a>-->
    <!--</li>-->
    <!--</ul>-->
    <!--</div>-->
    <!--</div>-->
    <!--<div class="parmeter-center-1">-->
    <!--<p>文档与手册</p>-->
    <!--<div class="parmeter-center-2">-->
    <!--<ul class="ul1">-->
    <!--<li v-for="item in parameterData3">{{item.name}}-->
    <!--<span>{{item.time}}</span>-->
    <!--</li>-->
    <!--</ul>-->
    <!--<ul class="ul2">-->
    <!--<li v-for="item in parameterData2" style="height: 38px;font-size: 12px;">-->
    <!--<a href="">下载</a>-->
    <!--</li>-->
    <!--</ul>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->

    <div class="parmeter-top">
      <p>常见问题</p>
    </div>
    <div class="parmeter-center">
      <div class="parmeter-box">
        <div class="parmeter-center-1" style="width: 100%">
          <ul class="ques" v-for="(item, ind) in qaq">
            <li @click="liShow(ind, item)">{{item.question}}
              <transition enter-active-class="animated slideInLeft">
                <i v-if="item.right" class="iconfont icon-arrow-right-copy-copy-copy"
                   style="float: right;color: black"></i>
              </transition>
              <transition enter-active-class="animated slideInDown">
                <i v-if="!item.right" class="iconfont icon-jiantou" style="float: right;color: black"></i>
              </transition>
            </li>
            <li :class="{show:item.isShow,hide:!item.isShow}">{{item.answer}}</li>
          </ul>
        </div>
      </div>
    </div>
    <back-to-top></back-to-top>
  </div>
</template>

<script>
  import BackToTop from "../../common/backToTop";

  export default {
    components: {BackToTop},
    name: "parameter",
    data() {
      return {
        isActive: -1,
        scrollY,
        navData: [
          {
            navtitle: "产品介绍"
          },
          {
            navtitle: "技术参数"
          },
          {
            navtitle: "常见问题"
          },
          {
            navtitle: "购买"
          },
          {
            navtitle: "服务支持"
          }
        ],
        colorShow: false,
        parameterData: [                 // 飞行器参数
          {
            name: "型号",
            paraData: 'L1Air'
          },
          {
            name: "尺寸（不带外框）",
            paraData: '480mm'
          },
          {
            name: "起飞重量",
            paraData: '920g'
          },
          {
            name: "型号",
            paraData: 'T650A'
          }
        ],
        parameterData1: [                // 飞行器1参数
          {
            name: "型号1",
            paraData: 'L1Air1'
          },
          {
            name: "尺寸（不带外框）1",
            paraData: '480mm'
          },
          {
            name: "起飞重量1",
            paraData: '920g'
          },
          {
            name: "型号1",
            paraData: 'T650A'
          }
        ],
        parameterData2: [                // 拍摄样片下载参数
          {
            name: "型号2",
            paraData: 'L1Air2',
            time: '2012-06-15'
          },
          {
            name: "尺寸（不带外框）2",
            paraData: '480mm',
            time: '2012-06-15'
          },
          {
            name: "起飞重量2",
            paraData: '920g',
            time: '2012-06-15'
          },
          {
            name: "型号2",
            paraData: 'T650A',
            time: '2012-06-15'
          }
        ],
        parameterData3: [                // 文档与手册参数
          {
            name: "型号3",
            paraData: 'L1Air3',
            time: '2012-06-15'
          },
          {
            name: "尺寸（不带外框）3",
            paraData: '480mm',
            time: '2012-06-15'
          },
          {
            name: "起飞重量3",
            paraData: '920g',
            time: '2012-06-15'
          },
          {
            name: "型号3",
            paraData: 'T650A',
            time: '2012-06-15'
          }
        ],
        qaq: [
          {
            question: 'L1 有哪些主要的用途？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          },
          {
            question: '1.Inspire 2的飞行速度是多少？',
            answer: '100000m/s',
            isShow: false,
            right: true
          }
        ]
      }
    },
    methods: {
      liShow(index, item) {
        this.qaq.forEach(i => {
          if (i.isShow !== this.qaq[index].isShow) {
            i.isShow = false;
            i.right = true;
          }
        })
        item.isShow = !item.isShow;
        item.right = !item.right;
      },
      goIndex() {
        this.$router.push({name: '首页'});
      },
      goPos(data) {
        if (data === 3 || data === 4)
          return;
        this.isActive = data;
        const cateItem = document.querySelectorAll('.parmeter-top');
        let total = cateItem[data].offsetTop;
        let distance = document.documentElement.scrollTop + 60 || document.body.scrollTop + 60 || window.scrollY + 60;
        let step = total / 50;
        if (total > distance) {
          smoothDown()
        } else {
          let newTotal = distance - total
          step = newTotal / 50;
          smoothUp()
        }

        function smoothDown() {
          if (distance < total) {
            distance += step;
            document.documentElement.scrollTop = distance;
            setTimeout(smoothDown, 10);
          } else {
            document.documentElement.scrollTop = total - 60
          }
        }

        function smoothUp() {
          if (distance > total) {
            distance -= step + 20;
            document.documentElement.scrollTop = distance;
            setTimeout(smoothUp, 10)
          } else {
            document.documentElement.scrollTop = total - 60
          }
        }
      }
    },
    mounted() {
      this.isActive = 0;
      this.$nextTick(function () {
        let cateItem = document.querySelectorAll('.parmeter-top');
        document.addEventListener('scroll', () => {
          let scrolled = document.documentElement.scrollTop + 60 || document.body.scrollTop + 60;
          if (scrolled > cateItem[2].offsetTop - 4) {
            this.isActive = 2;
          } else if (scrolled < cateItem[2].offsetTop && scrolled > cateItem[1].offsetTop - 4) {
            this.isActive = 1;
          } else if (scrolled < cateItem[1].offsetTop && scrolled > cateItem[0].offsetTop - 4) {
            this.isActive = 0;
          }
        })
      })
    }
  }
</script>

<style lang="scss" scoped>
  .show {
    line-height: 50px;
    height: 50px !important;
  }
  .hide {
    line-height: 50px;
    height: 0px !important;
  }
  .parmeter-page {
    .header {
      position: fixed;
      top: 0;
      width: 100%;
      height: 62px;
      z-index: 100;
      background: white;
      .header-center {
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: white;
        width: 1200px;
        height: 100%;
        margin: 0 auto;
        > span {
          margin-left: 40px;
          color: #333333;
          font-weight: 600;
        }
        > ul {
          display: flex;
          > li:nth-child(1) {
            /*color: #44a8f2;*/
          }
          > li {
            margin: 0 20px;
            color: #333333;
            cursor: pointer;
            &.active {
              color: #00aeef;
              font-weight: 600;
            }
          }
        }
      }
    }
    .img-show {
      margin-top: 60px;
      > ul {
        background: #141414;
        width: 100%;
        > li {
          display: block;
          width: 100%;
          position: relative;
          > img {
            width: 100%;
            height: 100%;
            display: block;
            margin: 0 auto;
          }
          .word1 {
            color: white;
            position: absolute;
            top: 195px;
            right: 200px;
            font-size: 28px;
            > span {
              font-size: 48px;
              font-weight: 600;
              /*color: #333333;*/
            }
            > div {
              font-size: 28px;
              /*color: #333333;*/
            }
          }
          .word2 {
            color: white;
            position: absolute;
            top: 195px;
            left: 200px;
            font-size: 28px;
            > span {
              font-size: 48px;
              font-weight: 600;
              /*color: #333333;*/
            }
            > h4 {
              font-weight: normal;
            }
          }
        }
      }
    }
    .parmeter-top {
      width: 100%;
      background: #ffffff;
      height: 100%;
      padding: 80px 0 60px;
      p {
        width: 1200px;
        font-size: 28px;
        color: #333333;
        font-weight: 600;
        margin: 0 auto;
        text-align: center;
      }
    }
    .parmeter-center {
      p {
        font-size: 28px;
        color: #707473;
      }
      .parmeter-box {
        width: 1200px;
        display: flex;
        margin: 0 auto;
        /*padding-bottom: 100px;*/
        .parmeter-center-1 {
          p {
            font-size: 24px;
            color: #666666;
            font-weight: 600;
            padding: 0 0 30px 0;
          }
          .ques {
            li:nth-child(1) {
              height: 40px;
              border-bottom: 1px solid #e5e5e5;
              padding-top: 20px;
              cursor: pointer;
              font-weight: 600;
              color: #333333;
              line-height: 40px;
            }
            li:nth-child(2) {
              width: 100%;
              height: 0px;
              overflow: hidden;
              transition: all .5s;
              color: #666666;
            }

          }
          .parmeter-center-2 {
            display: flex;
            .ul1 {
              width: 400px;
              color: #6ea8f2;
              li {
                padding-bottom: 20px;
                font-size: 16px;
                color: #005bd7;
                span {
                  display: block;
                  color: #999999;
                  font-size: 14px;
                  margin-top: 12px;
                }
              }
            }
            .ul2 {
              width: 215px;
              color: #707473;
              li {
                padding-bottom: 31px;
                font-size: 16px;
                color: #666666;
                a {
                  display: block;
                  padding: 2px 8px;
                  border: 1px solid #707473;
                  background: #f7f8f9;
                  color: #333333;
                  text-transform: uppercase;
                  width: 60px;
                  height: 30px;
                  text-align: center;
                  line-height: 30px;
                  font-size: 14px;
                }
                &:hover >a{
                  border: 1px solid #00aeef;
                  color: #00aeef;
                }
              }
            }
          }
        }
      }
    }
  }
</style>
